<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>libcoap: coap_logging(3)</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">libcoap<span id="projectnumber">&#160;4.2.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.8 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('man_coap_logging.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div><div class="header">
  <div class="headertitle"><div class="title">coap_logging(3)</div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>coap_logging</title><link rel="stylesheet" type="text/css" href="docbook-xsl.css" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /></head><body><div xml:lang="en" class="refentry" lang="en"><a id="id1337"></a><div class="titlepage"></div><div class="refnamediv"><h2>NAME</h2><p>coap_logging, coap_log, coap_get_log_level, coap_set_log_level, coap_set_log_handler, coap_package_name, coap_package_version, coap_set_show_pdu_output, coap_show_pdu — Work with CoAP logging</p></div><div class="refsynopsisdiv"><a id="_synopsis"></a><h2>SYNOPSIS</h2><p><span class="strong"><strong>#include &lt;coap2/coap.h&gt;</strong></span></p><p><span class="strong"><strong>void coap_log(coap_log_t <span class="emphasis"><em>level</em></span>, const char *<span class="emphasis"><em>format</em></span>, …);</strong></span></p><p><span class="strong"><strong>void coap_set_log_level(coap_log_t <span class="emphasis"><em>level</em></span>);</strong></span></p><p><span class="strong"><strong>coap_log_t coap_get_log_level(void);</strong></span></p><p><span class="strong"><strong>void coap_dtls_set_log_level(int <span class="emphasis"><em>level</em></span>);</strong></span></p><p><span class="strong"><strong>int coap_dtls_get_log_level(void);</strong></span></p><p><span class="strong"><strong>void coap_set_log_handler(coap_log_handler_t <span class="emphasis"><em>handler</em></span>);</strong></span></p><p><span class="strong"><strong>const char *coap_package_name(void);</strong></span></p><p><span class="strong"><strong>const char *coap_package_version(void);</strong></span></p><p><span class="strong"><strong>void coap_set_show_pdu_output(int <span class="emphasis"><em>use_fprintf</em></span>);</strong></span></p><p><span class="strong"><strong>void coap_show_pdu(coap_log_t <span class="emphasis"><em>level</em></span>, const coap_pdu_t *<span class="emphasis"><em>pdu</em></span>);</strong></span></p><p><span class="strong"><strong>const char *coap_endpoint_str(const coap_endpoint_t *<span class="emphasis"><em>endpoint</em></span>);</strong></span></p><p><span class="strong"><strong>const char *coap_session_str(const coap_session_t *<span class="emphasis"><em>session</em></span>);</strong></span></p><p>Link with <span class="strong"><strong>-lcoap-2</strong></span>, <span class="strong"><strong>-lcoap-2-gnutls</strong></span>,
<span class="strong"><strong>-lcoap-2-openssl</strong></span> or
<span class="strong"><strong>-lcoap-2-tinydtls</strong></span> depending on your (D)TLS library
type.</p></div><div class="refsect1"><a id="_description"></a><h2>DESCRIPTION</h2><p>The logging sub-system supports logging at different levels, and depending on
the selected logging level, outputs the appropriate information.</p><p>Logging by default is to stderr or stdout depending on the logging level of
the log entry.  It ia possible to send the logging information to an
application logging call-back handler for processing by the application.</p><p>The <span class="strong"><strong>coap_log</strong></span>() function is used to log information at the appropriate <span class="emphasis"><em>level</em></span>.
The rest of the parameters follow the standard <span class="strong"><strong>printf</strong></span>() function format.</p><p>Logging levels (<span class="strong"><strong>coap_log_t</strong></span>) are defined by (the same as for <span class="strong"><strong>syslog</strong></span>()), which
are numerically incrementing in value:</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
<span class="strong"><strong>LOG_EMERG</strong></span>
</span></dt><dd>
Emergency level (0).
</dd><dt><span class="term">
<span class="strong"><strong>LOG_ALERT</strong></span>
</span></dt><dd>
Alert level (1).
</dd><dt><span class="term">
<span class="strong"><strong>LOG_CRIT</strong></span>
</span></dt><dd>
Critical level (2).
</dd><dt><span class="term">
<span class="strong"><strong>LOG_ERR</strong></span>
</span></dt><dd>
Error level (3).
</dd><dt><span class="term">
<span class="strong"><strong>LOG_WARNING</strong></span>
</span></dt><dd>
Warning level (the default) (4).
</dd><dt><span class="term">
<span class="strong"><strong>LOG_NOTICE</strong></span>
</span></dt><dd>
Notice level (5).
</dd><dt><span class="term">
<span class="strong"><strong>LOG_INFO</strong></span>
</span></dt><dd>
Information level (6).
</dd><dt><span class="term">
<span class="strong"><strong>LOG_DEBUG</strong></span>
</span></dt><dd>
Debug level (7).
</dd></dl></div><p>The <span class="strong"><strong>coap_set_log_level</strong></span>() function is used to set the current logging <span class="emphasis"><em>level</em></span>
for output by any subsequent <span class="strong"><strong>coap_log</strong></span>() calls.  Output is only logged if the
<span class="strong"><strong>coap_log</strong></span>() <span class="emphasis"><em>level</em></span> definition is smaller than or equal to the curent logging
<span class="emphasis"><em>level</em></span>.</p><p>The <span class="strong"><strong>coap_get_log_level</strong></span>() function is used to get the current logging level.</p><p>The <span class="strong"><strong>coap_dtls_set_log_level</strong></span>() function is used to set the logging <span class="emphasis"><em>level</em></span>
for output by the DTLS library for specific DTLS information. Usually, both
<span class="strong"><strong>coap_set_log_level</strong></span>() and <span class="strong"><strong>coap_dtls_set_log_level</strong></span>() would be set to the
same <span class="emphasis"><em>level</em></span> value. If the logging level is set to greater than LOG_DEBUG,
the underlying TLS library may get more verbose in its output.</p><p>The <span class="strong"><strong>coap_dtls_get_log_level</strong></span>() function is used to get the current logging
level for the DTLS library.</p><p>The <span class="strong"><strong>coap_set_log_handler</strong></span>()* function can be used to define an alternative
logging handler for processing the logging messages.  The logging handler
prototype is defined as:</p><pre class="programlisting">typedef void (*coap_log_handler_t) (coap_log_t level, const char *message);</pre><p>The <span class="strong"><strong>coap_package_name</strong></span>() function returns the name of this library.</p><p>The <span class="strong"><strong>coap_package_version</strong></span>() function returns the version of this library.</p><p>The <span class="strong"><strong>coap_set_show_pdu_output</strong></span>() function defines whether the output from
<span class="strong"><strong>coap_show_pdu</strong></span>() is to be either sent to stdout/stderr, or output using
<span class="strong"><strong>coap_log</strong></span>().  <span class="emphasis"><em>use_fprintf</em></span> is set to 1 for stdout/stderr (the default), and
<span class="emphasis"><em>use_fprintf</em></span> is set to 0 for <span class="strong"><strong>coap_log</strong></span>().</p><p>The <span class="strong"><strong>coap_show_pdu</strong></span>() function is used to decode the <span class="emphasis"><em>pdu</em></span>, outputting as
appropriate for logging <span class="emphasis"><em>level</em></span>.  Where the output goes is dependent on
<span class="strong"><strong>coap_set_show_pdu_output</strong></span>().</p><p>The <span class="strong"><strong>coap_endpoint_str</strong></span>() function returns a description string of the
<span class="emphasis"><em>endpoint</em></span>.</p><p>The <span class="strong"><strong>coap_session_str</strong></span>() function is used to get a string containing the
information about the <span class="emphasis"><em>session</em></span>.</p></div><div class="refsect1"><a id="_return_values"></a><h2>RETURN VALUES</h2><p>The <span class="strong"><strong>coap_package_name</strong></span>() and <span class="strong"><strong>coap_package_version</strong></span>() return the appropriate
zero-terminated character string.</p><p>The <span class="strong"><strong>coap_get_log_level</strong></span>() function returns the current logging level.</p><p>The <span class="strong"><strong>coap_dtls_get_log_level</strong></span>() function returns the current logging level
for the DTLS library specifics.</p><p>The <span class="strong"><strong>coap_endpoint_str</strong></span>() function returns a description string of the
<span class="emphasis"><em>endpoint</em></span>.</p><p>The <span class="strong"><strong>coap_session_str</strong></span>() function returns a description string of the
<span class="emphasis"><em>session</em></span>.</p></div><div class="refsect1"><a id="_see_also"></a><h2>SEE ALSO</h2><p><a href="man_coap_context.html" target="_self"><span class="strong"><strong>coap_context</strong></span>(3)</a> and <a href="man_coap_session.html" target="_self"><span class="strong"><strong>coap_session</strong></span>(3)</a></p></div><div class="refsect1"><a id="_further_information"></a><h2>FURTHER INFORMATION</h2><p>See "RFC7252: The Constrained Application Protocol (CoAP)" for further
information.</p></div><div class="refsect1"><a id="_bugs"></a><h2>BUGS</h2><p>Please report bugs on the mailing list for libcoap:
<a class="ulink" href="mailto:libcoap-developers@lists.sourceforge.net" target="_top">libcoap-developers@lists.sourceforge.net</a></p></div><div class="refsect1"><a id="_authors"></a><h2>AUTHORS</h2><p>The libcoap project &lt;<a class="ulink" href="mailto:libcoap-developers@lists.sourceforge.net" target="_top">libcoap-developers@lists.sourceforge.net</a>&gt;</p></div></div></body></html> coap_logging(3)</p>
</div></div><!-- contents -->
</div><!-- PageDoc -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Fri Dec 27 2024 09:57:44 for libcoap by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.8 </li>
  </ul>
</div>
</body>
</html>
